package com.wm.web.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.NumberUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import com.wm.bean.MenuType;
import com.wm.bean.Orders;
import com.wm.bean.ResMenu;
import com.wm.bean.Restaurant;
import com.wm.bean.Shopkeeper;
import com.wm.bean.User;
import com.wm.comm.Constant;
import com.wm.comm.MD5;
import com.wm.comm.PinYinUtil;
import com.wm.service.MenuTypeService;
import com.wm.service.OrdersService;
import com.wm.service.ResMenuService;
import com.wm.service.RestaurantService;
import com.wm.service.ShopkeeperService;
import com.wm.service.UserService;
import com.wm.service.web.PageList;
import com.wm.service.web.Pages;
import com.wm.web.interceptor.RemoteAddrAware;
import com.wm.web.interceptor.ShopkeeperSessionAware;
import com.wm.web.servlet.*;
import com.wm.web.ui.OptionsInt;
import com.wm.web.ui.OptionsLong;

public class ShopkeeperOrders extends BaseAction implements SessionAware,ShopkeeperSessionAware{
	private static final Log logger = LogFactory.getLog(ShopkeeperOrders.class);
	
	private OrdersService ordersService;

	public OrdersService getOrdersService() {
		return ordersService;
	}

	public void setOrdersService(OrdersService ordersService) {
		this.ordersService = ordersService;
	}
	
	private ShopkeeperSession shopkeeperSession;
	private Map session;
	
	public ShopkeeperSession getShopkeeperSession() {
		return shopkeeperSession;
	}

	public void setShopkeeperSession(ShopkeeperSession shopkeeperSession) {
		this.shopkeeperSession = shopkeeperSession;
	}

	public Map getSession() {
		return session;
	}
	
	public void setSession(Map session) {
		this.session = session;
	}

	private int time = 7;		//时间

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	private PageList pageList;
	
	public PageList getPageList() {
		return pageList;
	}

	public void setPageList(PageList pageList) {
		this.pageList = pageList;
	}

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return INPUT;
		}
	}

	/**
	 * 初始页
	 */
	public String index(){
		Pages pages = new Pages();
		pages.setPage(this.getPage());
		pages.setPerPageNum(Constant.PAGE_NUM);
		if (this.getTotal() > 0) {
			pages.setTotalNum(this.getTotal());
		}
		pages.setFileName("/shopkeeper_orders.action?time="+this.time);
		this.setPageList(this.getOrdersService().findOrdersByResIdTime(shopkeeperSession.getSkid(),this.time,"id", 1, pages));
		return SUCCESS;
	}

}
